{include file="common/header"}
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-inline">
                <input type="text" name="nickname" required="" lay-verify="required"
                       autocomplete="off" value="{$info.nickname}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录名</label>
            <div class="layui-input-inline">
                <input type="text" name="login_name" required="" lay-verify="required"
                       autocomplete="off" value="{$info.login_name}" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label">
                <span class="x-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" value="{$info.email}" id="L_email" name="email" required="" lay-verify="email"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass" name="pass" required=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                6到16个字符
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">确认密码</label>
            <div class="layui-input-inline">
                <input type="password" id="L_repass" name="repass" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">确认修改</button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            var field = data.field;
            if (field.pass && field.repass){
                var reg = /(.+){6,12}$/;
                if (!reg.test(field.pass)){
                    layer.msg('密码必须6到12位');
                    return false;
                }else if(field.pass != field.repass){
                    layer.msg('两次密码不一致');
                    return false;
                }
            }
            var index = layer.load(1)
            $.post("{:url('editUser')}",{
                id:'{$info.id}',
                data:field
            },function (res) {
                if (res.success){
                    layer.msg(res.msg,{icon:1},function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                    })
                } else{
                    layer.close(index);
                    layer.msg(res.msg,{icon:2})
                }
            });

            return false;
        });


    });
</script>
</body>

</html>